<?php

$taskName = $_POST['name'] ?? '';
$taskContent = $_POST['content'] ?? '';

$dns = "sqlsrv:Server=LAPTOP-LD8O4C6L\SQLEXPRESS;Database=TaskManagement";
$db = new PDO($dns,"sa","123456");
$sql = "insert into TaskList(TaskName,TaskContent)values ('{$taskName}','{$taskContent}')";
$result = $db->exec($sql);
if ($result){
    echo "添加成功.<a href=\"task_list.php\">返回任务列表</a>";
}else{
    echo "添加失败";
}
?>